home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_052 / tek4010 / window.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  4KB  |  157 lines

  1. /****************************************************
  2.  * vt100 emulator - window/keyboard support
  3.  * This has been rationalized and speeded up quite a bit. (but wait for
  4.  * AmigaDOS 1.2!) The Tek support is put in in the appropriate place
  5.  * The function emit() is now never used to handle remote characters.
  6.  *    T.Whelan Oct 1986
  7.  *
  8.  *           860823 DBW - Integrated and rewrote lots of code
  9.  *      v2.0 860809 DBW - Major rewrite
  10.  *      v1.1 860720 DBW - Switches, 80 cols, colors, bug fixes
  11.  *      v1.0 860712 DBW - First version released
  12.  *
  13.  ****************************************************/
  14.  
  15. #include "vt100.h"
  16.  
  17. /* forward declarations for LATTICE */
  18. void filename();
  19. void emits();
  20. void emit();
  21. void emitbatch();
  22. void cursoroff();
  23. void cursoron();
  24.  
  25. /************************************************
  26. *  function to print a string
  27. *************************************************/
  28. void emits(string)
  29. char string[];
  30.     {
  31.     int i;
  32.     char c;
  33.  
  34.     i=0;
  35.     while (string[i] != 0)
  36.         {
  37.         c=string[i];
  38.         if (c == 10) emit(13);
  39.         emit(c);
  40.         i += 1;
  41.         }
  42.     }
  43.  
  44. /*************************************************
  45. *  function to output ascii chars to window
  46. *************************************************/
  47. void emit(c)
  48. char c;
  49.     {
  50.     switch( c )
  51.         {
  52.         case '\t':
  53.         x += 64 - ((x-MINX) % 64);
  54.         break;
  55.  
  56.         case 10:  /* lf */
  57.         y += 8;
  58.         break;
  59.  
  60.         case 13:  /* cr */
  61.         x = MINX;
  62.         break;
  63.  
  64.         case 8:   /* backspace */
  65.         x -= 8;
  66.         if (x < MINX) x = MINX;
  67.         break;
  68.  
  69.         case 12:     /* page */
  70.         x = MINX;
  71.         y = MINY;
  72.         SetRast(mywindow->RPort, 0);
  73.         break;
  74.  
  75.         case 7:     /* bell */
  76.         DisplayBeep(NULL);
  77.         break;
  78.  
  79.         default:
  80.         if (c < ' ' || c > '~') break;
  81.        emitbatch(1, &c);
  82.         } /* end of switch */
  83.  
  84.     while (x > MAXX) x -= 8;
  85.     while (y > MAXY) {
  86.         y -= 8;
  87.         x  = MINX;
  88.         ScrollRaster(mywindow->RPort, 0, 8, MINX, MINY-6, MAXX+7, MAXY+1);
  89.         }
  90.     }
  91.  
  92. /*************************************************
  93. *  function to output ascii chars to window.
  94. * this function will only ever get printable characters.
  95. *************************************************/
  96. void emitbatch(la,lookahead)
  97. int la;
  98. char *lookahead;
  99.     {
  100.     int i;
  101.  
  102.     if (TekMode) {
  103.       for (i = 0; i < la; i++)
  104.          Tek(lookahead[i]);
  105.       return;
  106.       }
  107.  
  108.     Move(mywindow->RPort,x, y);
  109.     i = x / 8;
  110.     if (i+la > maxcol) la = maxcol-i;
  111.  
  112. /* the logic here is built for speed, but I think that all the time is
  113.  * spent in Text(), so there is not much gain */
  114.     if (curmode&BOLD)
  115.              SetAPen(mywindow->RPort, 3);
  116.  
  117.     if (curmode&REVERSE)
  118.         SetDrMd(mywindow->RPort, JAM2+INVERSVID);
  119.  
  120.     Text(mywindow->RPort,lookahead, la);
  121.  
  122.     if (curmode&UNDERLINE) {
  123.          Move(mywindow->RPort, x-1 ,y+1);
  124.          Draw(mywindow->RPort, x+8*la+8, y+1);
  125.          }
  126.  
  127.      if (curmode&BOLD)
  128.           SetAPen(mywindow->RPort, 1);
  129.  
  130.     if (curmode&REVERSE) 
  131.         SetDrMd(mywindow->RPort, JAM2);
  132.  
  133.     x += (8 * la);
  134.     
  135.     }
  136.  
  137. /******************************
  138. * Manipulate cursor
  139. ******************************/
  140. void cursoroff()
  141.     {
  142.     SetDrMd(mywindow->RPort, COMPLEMENT);
  143.     SetAPen(mywindow->RPort, 3);
  144.     RectFill(mywindow->RPort, x, y-6, x+8, y);
  145.     SetAPen(mywindow->RPort,1);
  146.     SetDrMd(mywindow->RPort, JAM2);
  147.     }
  148.  
  149. void cursoron()
  150.     {
  151.     SetDrMd(mywindow->RPort, COMPLEMENT);
  152.     SetAPen(mywindow->RPort,3);
  153.     RectFill(mywindow->RPort, x, y-6, x+8, y);
  154.     SetAPen(mywindow->RPort,1);
  155.     SetDrMd(mywindow->RPort, JAM2);
  156.     }
  157.